#include "currentThread.h"

pid_t currentThread::getTid() {
    if (tid == 0)
            return static_cast<pid_t>(syscall(SYS_gettid));
        else
            return tid;
}

std::string currentThread::getTidAsString() {
        pid_t cache = getTid();
        char buf[100];
        sprintf(buf, "%d", static_cast<int>(cache));
        return std::string(buf);
}

namespace currentThread
{
    __thread pid_t tid = 0;
} // namespace name
